<template>
	<view class="container">
		<view class="container-bg"></view>
		<view class="container-form">
			<view class="container-form-item">
				<icon class="iconfont icon-shouji"></icon>
				<input v-model="ufrom.account" placeholder="请输入账号"/>
			</view>
			<view class="container-form-item">
				<icon class="iconfont icon-mima"></icon>
				<input  v-model="ufrom.pwd" type="password" placeholder="请输入密码"/>
				<icon :class="switchPwd?'iconfont icon-chakan':'iconfont icon-yincang'" @click="handleSwitchPwd"></icon>
			</view>
			<button class="container-form-submit" @click="login">登录</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				switchPwd:false,//查看隐藏密码
				ufrom:{
					account:'',
					pwd:''
				}
			};
		},
		methods:{
			handleSwitchPwd(){
				this.switchPwd=!this.switchPwd;
			},
			login(){
				if(!this.ufrom.account) return uni.showToast({
					icon:"none",title:"请输入账号！"
				})
				if(!this.ufrom.pwd) return uni.showToast({
					icon:"none",title:"请输入密码！"
				})
				uni.request({
					url:'/admin/mao/login',
					method:"POST",
					data:this.ufrom,
					success: (res) => {
						console.log('res',res)
						if(res.data.code!=200){
							uni.showToast({
								icon:"error",
								title:res.data.msg
							})
						}
					}
				})
			}
		}
	}
</script>

<style lang="less">
.container{
	background-color: #F6F6F6;
	width: 100%;
	height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	&-bg{
		width:100%;
		height: 50%;
		background-color: #609B22;
		border-bottom-left-radius: 10%;
		border-bottom-right-radius: 10%;
		position: absolute;
		top:0;
		z-index: 1;	
	}
	&-form{
		width: 90%;
		background-color: white;
		box-sizing: border-box;
		padding:80rpx 20rpx;
		border-radius: 5%;
		z-index: 1;	
		&-item{
			display: flex;
			flex-direction: row;
			padding: 60rpx 0;
			border-bottom: 1px solid gainsboro;
			.iconfont{
				font-size: 40rpx;
				margin-right: 10rpx;
				margin-top:5rpx;
			}
			&-input{
				width: 70%;
				margin-right: 10%;
			}
		}
		&-submit{
			margin-top: 100rpx !important;
			color:white;
			background-color: #82BE20;
			border:none;
		}
	}
}

</style>
